<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class tracking_model extends MY_Model
{
	function tracking_model()
	{
		parent::MY_Model();
	}
	
	function selfserving_report_banner_tracking($page = 1, $limit = 20)
	{
		$result = $this->getRowsOnMultiQuery("CALL selfserving_report_banner_tracking($page, $limit);", 'object');
		$data = array();
		$data['items'] = $result[0];
		$data['pages'] = (int)$result[1][0]->totalpage;
		return $data;
	}
	
	function selfserving_system_tracking_banner_running_showly($page = 1, $limit = 20)
	{
		$result = $this->getRowsOnMultiQuery("CALL selfserving_system_tracking_banner_running_showly($page, $limit);", 'object');
		$data = array();
		$data['items'] = $result[0];
		$data['pages'] = (int)$result[1][0]->totalpage;
		return $data;
	}
    
    function selfserving_get_group_by_type($typegroup)
    {
        $ci = & get_instance();
        $db = $ci->load->database('slave1',true);
        $this->__setDb($db);
        $data = $this->getRows("CALL selfserving_get_group_by_type($typegroup)");
		return $data;
    }
    
    function selfserving_tracking_js_get_lstbanners($typegroup,$groupid,$key,$page,$rownum,$typeview)
    {
        $ci = & get_instance();
        $db = $ci->load->database('slave1',true);
        $this->__setDb($db);
        $result = $this->getRowsOnMultiQuery("CALL selfserving_tracking_js_get_lstbanners('$typegroup','$groupid','$key','$page','$rownum','$typeview')");
        $data['items'] = $result[0];
		$data['totalpage'] = (int)$result[1][0]['totalpage'];
		return $data;
    }
    
    function selfserving_tracking_js_get_lstzone_by_bannerid($bannerid)
    {
        $ci = & get_instance();
        $db = $ci->load->database('slave1',true);
        $this->__setDb($db);
        $data = $this->getRows("CALL selfserving_tracking_js_get_lstzone_by_bannerid('$bannerid')");
		return $data;
    }
}